
import Axios from 'axios'
// 设置公共的url接口
// Axios.defaults.baseURL = 'http://8.130.48.251:8071/api/';
// 测试接口
Axios.defaults.baseURL = 'http://localhost:8090/api/';

// 添加请求拦截器
Axios.interceptors.request.use(function (config) {
	// 在发送请求之前做些什么
	if (localStorage.getItem('token')) {
		// Axios.defaults.headers.common['Authorization'] = localStorage.getItem('access_token');
		console.log('config.headers');
		console.log(config.headers);
		config.headers.AUTHORIZATION = localStorage.getItem('token')
		console.log(config.headers);
	}
	return config;
}, function (error) {
	// 对请求错误做些什么
	return Promise.reject(error);
});

// ##############################################################################################################

// 首页菜单：/api/home/menu
export const menuList = () => {
	return Axios.get('home/menu').then(res => res.data);
}
// 首页slogan：/api/home/slogan
export const sloganList = () => {
	return Axios.get('home/slogan').then(res => res.data);
}

// 笔记列表：/api/note/list
export const noteList = () => {
	return Axios.get('note/note_list').then(res => res.data);
}
// 笔记分类：/api/note/kind
export const noteKindList = () => {
	return Axios.get('note/note_kind').then(res => res.data);
}

// 文档列表：/api/api/list
export const apiList = () => {
	return Axios.get('note/api_list').then(res => res.data);
}
// 文档分类：/api/api/kind
export const apiKindList = () => {
	return Axios.get('note/api_kind').then(res => res.data);
}

// 作品列表：/api/api/list
export const opusList = () => {
	return Axios.get('demo/list').then(res => res.data);
}
// 作品分类：/api/api/kind
export const opusKindList = () => {
	return Axios.get('demo/kind').then(res => res.data);
}

// 关于
export const aboutList = () => {
	return Axios.get('about/about').then(res => res.data);
}
// 开源
export const gitList = () => {
	return Axios.get('about/git').then(res => res.data);
}
// 留言
export const contactList = () => {
	return Axios.get('about/contact').then(res => res.data);
}